export function getEditPrizeConfigProps(form, list, isAdd) {
  if (form && form.continuous && list && typeof list === 'object') {
    console.log(form.continuous, list, isAdd)
    let { times, continuousTimes } = list
    if (form.continuous === '累计') {
      if (!(times && Array.isArray(times))) times = []
      if (!isAdd) {
        // 编辑
        let i = times.findIndex((item) => item && item.prizeid === form.prizeid)
        if (i > -1) {
          times[i] = form
        }

        console.log(i, form, '....编辑...times......', times)
      } else {
        console.log(form, '....新增...times......', times)

        times.unshift(form)
      }
    } else if (form.continuous === '连续') {
      if (!(continuousTimes && Array.isArray(continuousTimes))) continuousTimes = []
      if (!isAdd) {
        let i = continuousTimes.findIndex((item) => item && item.prizeid === form.prizeid)
        if (i > -1) {
          continuousTimes[i] = form
        }
      } else {
        continuousTimes.unshift(form)
      }
    }
  }
  const props = {
    configValue: list,
    configItem: 'prizeConfig',
  }
  console.log('传递参数---', props)
  return props
}

export function getDeletePrizeConfigProps(form, list) {
  console.log(form, '....getDeletePrizeConfigProps......', list)
  let newList = {}
  if (form && form.continuous && list && typeof list === 'object') {
    console.log(form.continuous)
    let { times, continuousTimes } = list
    if (form.continuous === '累计' && times && Array.isArray(times)) {
      // 编辑
      newList.times = times.filter((item) => item && item.prizeid !== form.prizeid)

      console.log(times, form, '....编辑...times......', newList)
    } else if (form.continuous === '连续' && continuousTimes && Array.isArray(continuousTimes)) {
      newList.continuousTimes = continuousTimes.filter(
        (item) => item && item.prizeid !== form.prizeid
      )
    }
  }
  const props = {
    configValue: { ...list, ...newList },
    configItem: 'prizeConfig',
  }
  console.log('传递参数---', props)
  return props
}
